package JavaBase.Proxy.MineProxy;

import JavaBase.Proxy.Subject;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class MyProxySubject implements MyInvocationHandler{
    private Subject subject;

    public MyProxySubject(Subject sb){
        subject = sb;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) {
        System.out.println("before");
        Object result = null;
        try {
            result = method.invoke(subject, args);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        System.out.println("after");
        return result;
    }
}
